<?php
/**
 * Created by PhpStorm.
 * User: Sing
 * Date: 16/10/18
 * Time: 14:05
 */
ini_set("display_errors", "On");//开启错误显示
define('INDEX', true);
require_once '../Lib/Sing_core.php';
if($_GET['pwd'] != '123qweasd') exit;
$key = $_GET['key'];
$queue = new sing_queue();
$Name = 'test102715003';
$return = $queue->queue($Name, $key ,30);

redis2('set','test','Ok');
echo redis2('get','test').'<br />';
echo '补位动作工作状态:'.redis2('get','Run'.$Name).'<br />';

if($return == 0){
    echo 'true|在队列中'.'<br />';
    write_cache($key,'redis_log/'.date('Ymd',TIME).'_'.$key.'log');
}else{
    echo 'false|在排队中,当前位置:'.$return.'<br />';
}
$LuckQueue = 'Luck'.$Name;
$WaitQueue = 'Wait'.$Name;
echo '等待队列数:'.redis2('zcard',$WaitQueue)."<br />";
echo "服务中队列数:".redis2('zcard',$LuckQueue)."<br />";

$list = $queue->keygetnum($LuckQueue,0);
echo count($list)."<br />";
foreach($list as $v){
    echo '队列中Key:'.$v.':'.redis2('zscore',$LuckQueue , $v).'<br />';
}
//echo 'OK';